<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
    <style>
        * {
            padding:0;
            margin:0;
        }
        .box{
            width:400px;
            height: 120px;
            margin:100px auto;
            border: 1px solid #000;
            padding:20px;
            background:rgba(161,255,223,.8);
        }
        .box p {
            padding-left:150px;
            height:120px;
            background-position: 20px top;
            background-repeat: no-repeat;
        }
    </style>
</head>
<body>
<script>
    window.onload = function(){
        var demo = document.getElementById("demo");
        var child = demo.children;
        var date = new Date();
        var hours = date.getHours();
        if(hours<9){
          child[0].innerHTML = "早上好，新的一天新的开始" ;
            child[0].style.backgroundImage = " url(images/1.gif)";
        }else if(hours <12){
            child[0].innerHTML = "上午好，好好学习" ;
            child[0].style.backgroundImage = " url(images/2.jpg)";
        }else if(hours <18){
            child[0].innerHTML = "下午好，天天向上" ;
            child[0].style.backgroundImage = " url(images/4.jpg)";
            document.body.style.backgroundImage = " url(images/1.jpg)";
        }else if(hours <=23){
            child[0].innerHTML = "晚上好，好好复习今天的功课哦" ;
            child[0].style.backgroundImage = " url(images/5.jpg)";
        }
    }

</script>
<div class="box" id= "demo">
    <p>现在是上午，好好学习</p>
    <div></div>
</div>
</body>
</html>